/**注解加载，有源码的类通常采用本方法注册Bean
 * 除Abstract和Parent属性外其它均可以通过相关注解来实现与XML同样的功能
 * 内部通常是通过构造器方式创建对象
 */
package com.example.demospringbootbean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Primary   //当多个候选者有资格自动装配依赖项时，应优先考虑bean
@Scope("prototype")
@Lazy    //延迟加载
@DependsOn(value = {"BeanA"})
public class BeanB {
    @Value("Define by Annotation")
    private String message;
    public void setMessage(String message){
        this.message  = message;
    }
    public void getMessage(){
        System.out.println("BeanB Message : " + message);
    }
}
